#coding = utf-8
import copy
def turn_left(n):
    n_static = copy.deepcopy(n)
    n_add = []
    len_son = int(len(n[0])/2)
    len_fa = int(len(n))
    i = 0
    while i < len_fa:
        n_move = n[i][0:len_son]
        n_move.reverse()
        n_add.insert(0, n_move)
        del n_static[i][0:len_son]
        i += 1
    return n_add + n_static
def turn_right(n):
    n_static = copy.deepcopy(n)
    n_add = []
    len_son = int(len(n[0])/2)
    len_fa = int(len(n))
    i = 0
    while i < len_fa:
        n_move = n[i][len_son:]
        n_move.reverse()
        n_add.insert(0, n_move)
        del n_static[i][len_son:]
        i += 1
    return n_add + n_static
m = input('加密解密(0 or 1)？')
n = [list(input('字符串输入'))]
k = list(input('解密加密取反'))
for i in k:
    if i == '0':
        n = turn_left(n)
    else:
        n = turn_right(n)
if m == '0':
    print(n)
else:
    print(n[::-1])